<?php

namespace app\api\controller;

use app\services\QrcodeService;
use support\Request;

class QrcodeController
{
    public function generate(Request $request)
    {
        try {
            $id = $request->post('id');
            $type = $request->post('type', 'article');

            $data = QrcodeService::generate($id, $type);
            return ok_rsp('成功', ['qrcode_url' => $data]);
        } catch (\Exception $e) {
            return e_rsp($e);
        }
    }
}